<script>
$(function () {
	$('#{{ field_id }}').closest('div.control-group').attr('class', 'control-group');
	$('#{{ field_id }}').parent().children().remove('.help-inline');
	
	{% if errors|length > 0 %}
    	$('#{{ field_id }}').closest('div.control-group').addClass('error');
    	
    	{% for error in errors %}
	    $('#{{ field_id }}').parent().append('<span class="help-inline">{{ error.messageTemplate|trans(error.messageParameters, 'validators') }}</span>');
	    {% endfor %}
	{% else %}
	    $('#{{ field_id }}').closest('div.control-group').addClass('success');
	{% endif %}
});
</script>